const app = getApp();
const util = require('../../utils/util.js');

Component({
  options: {
    addGlobalClass: true,
  },
  /**
   * 组件的属性列表
   */
  properties: {
    pageName: String,
    showNav: {
      type: Boolean,
      value: false
    },
    showHome: {
      type: Boolean,
      value: true
    },
    bgColor: String,
    fontColor: String,
    iconColor: String,
    back: {
      type: Boolean,
      value: false
    },
    home: {
      type: Boolean,
      value: false
    },
    searchTop: String,
    searchInput: String,
    searchValue: String
  },

  /**
   * 组件的初始数据
   */
  data: {
    navHeight: app.globalData.navHeight,
    navTop: app.globalData.navTop,
    searchWidth: app.globalData.navPosition,
    navRight: app.globalData.menuButtonwidth

  },

  /**
   * 组件的方法列表
   */
  methods: {
    //回退
    navBack: function() {
      try {
        wx.navigateBack({
          delta: 1,
          fail: function(e) {

          }
        })
      } catch (e) {
        console.log(e)
      }

    },

    toSearch: function(){

      util.navigateTo('../search/search')
    },

    //回主页
    toIndex: function() {

      wx.reLaunch({
        url: '../index/index'
      })

    }

  }
})